package spring.my.db.sharding.demo.controller;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import spring.my.db.sharding.demo.response.CommonResponse;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/demo")
public class DemoController {


    @ResponseBody
    @RequestMapping("/date")
    public CommonResponse<LocalDateTime> demo(@RequestBody @JsonDeserialize LocalDateTime dateTime) {

        return CommonResponse.getInstance(dateTime);
    }

    @ResponseBody
    @RequestMapping("/date/2")
    public CommonResponse<LocalDateTime> demo2(@RequestBody LocalDateTime dateTime) {

        return CommonResponse.getInstance(dateTime);
    }

    @ResponseBody
    @RequestMapping("/date/3")
    public CommonResponse<A> demo2(@RequestBody A a) {

        return CommonResponse.getInstance(a);
    }

    public static class A {
//        @JsonDeserialize
//        @JsonSerialize
        private LocalDateTime dateTime;

        public LocalDateTime getDateTime() {
            return dateTime;
        }

        public void setDateTime(LocalDateTime dateTime) {
            this.dateTime = dateTime;
        }
    }


}
